package pub.xspace.nova.article.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import jakarta.annotation.Resource;
import pub.xspace.nova.article.domain.Article;
import pub.xspace.nova.article.mapper.ArticleMapper;
import pub.xspace.nova.article.service.ArticleService;

@Service
public class ArticleServiceImpl implements ArticleService {

	@Resource
	private ArticleMapper articleMapper;

	@Override
	public Article getById(String id) {
		return articleMapper.selectById(id);
	}

	@Override
	public List<Article> getByParams(Article article) {
		return articleMapper.selectByParams(article);
	}

	@Override
	public int insert(Article article) {
		return articleMapper.insert(article);
	}

	@Override
	public int updateById(Article article) {
		return articleMapper.updateById(article);
	}

	@Override
	public int deleteById(String id) {
		return articleMapper.deleteById(id);
	}

	@Override
	public int deleteByIds(List<String> ids) {
		return articleMapper.deleteByIds(ids);
	}

	@Override
	public PageInfo<Article> getPage(Integer pageNum, Integer pageSize, Article article) {
		PageHelper.startPage(pageNum, pageSize);
		List<Article> articles = articleMapper.selectByParams(article);

		return PageInfo.of(articles);
	}

}
